package temple.util;

import java.util.Calendar;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class DateUtil {


    /**
     * 6、8位时间格式加减
     *
     * @param time
     * @return
     * @version 1.0
     * @author temple
     */
    public String getTimeAdd(String time, int num) {
        Calendar cal = Calendar.getInstance();
        String dateStr = "00:00";
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            cal.setTime(sdf.parse(time));//放入时间
            cal.add(Calendar.MINUTE, num);//时间加上num分钟
            dateStr = sdf.format(cal.getTime());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("===[早退].time=" + time + ",num=" + num + ",dateStr=" + dateStr);
        return dateStr;
    }

}
